home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Monster Media 1996 #15
/
Monster Media Number 15 (Monster Media)(July 1996).ISO
/
prog_c
/
cuj0696.zip
/
DWYER.ZIP
/
SPECTRAL.TST
/
EUCLSTEP.CX
< prev
next >
Wrap
Text File
|
1996-01-29
|
2KB
|
53 lines
/* ============ */
/* euclstep.cx */
/* ============ */
#include <xtendefs.h>
#define P(S)
/* ==================================================================== */
/* EuclStep - Performs Step S2 (Euclidean Step) of the Spectral Test */
/* ==================================================================== */
void
EuclStep(USHORT *XH, USHORT *XHP, USHORT *XP, USHORT *XPP,
USHORT *XS, USHORT *XU, USHORT *XV)
{
for (;;)
{
USHORT T1[NE], T2[NE];
XDIV(XHP, XH, T1); /* q = h'/ h */
XFLOOR(T1, T1); /* q = floor(q) */
XMULT(XH, T1, T2); /* h * q */
XSUB(XHP, T2, XU); /* u = h' - qh */
XMULT(XP, T1, T2); /* p * q */
XSUB(XPP, T2, XV); /* v = p' - qp */
XSQR(XU, T1); /* u * u */
XSQR(XV, T2); /* v * v */
XADD(T1, T2, T1); /* u^2 + v^2 */
if (XGTE(T1, XS)) /* if (s <= u^2 + v^2) */
{
break; /* Algorithm complete */
}
XCOPY(T1, XS); /* s <- u^2+v^2 */
XCOPY(XH, XHP); /* h' <- h */
XCOPY(XU, XH); /* h <- u */
XCOPY(XP, XPP); /* p' <- p */
XCOPY(XV, XP); /* p <- v */
P(XPRINTF("Next EuclStep: XH = ", XH, NDEC));
P(XPRINTF(" XHP = ", XHP, NDEC));
P(XPRINTF(" XP = ", XP, NDEC));
P(XPRINTF(" XPP = ", XPP, NDEC));
P(XPRINTF(" XS = ", XS, NDEC));
P(XPRINTF(" XU = ", XU, NDEC));
P(XPRINTF(" XV = ", XV, NDEC));
}
P(exit(1));
P(printf("\nExit Eucl: XH = %.Lf, XHP = %.Lf, XP = %.Lf, XPP = %.Lf\n",
*XH, *XHP, *XP, *XPP));
P(printf("\t S = %.Lf, U = %.Lf, V = %.Lf\n", *S, *U, *V));
}